/**
 *                     Remixvym (version 0.8.3)
 *             Copyright (c) 2010 by RemixLab, DISI-UNAL
 *            http://www.disi.unal.edu.co/grupos/remixlab/
 *
 * This Java package provides classes to visualize Mind Maps created in VYM
 * (View Your Mind) in a Processing Sketch
 *
 * @author Alvaro Lopez, Juan Baquero, Gabriel Bobadilla
 *
 * This source file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * A copy of the GNU General Public License is available on the World Wide Web
 * at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by
 * writing to the Free Software Foundation, 51 Franklin Street, Fifth Floor
 * Boston, MA 02110, USA
 */

package remixlab.remixvym;

import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
//import java.io.IOException;
//import napplet.NApplet;
//import napplet.NAppletManager;
import processing.core.PApplet;
import processing.core.PConstants;
import processing.core.PImage;
import processing.core.PGraphics;
import remixlab.remixvym.core.graphics.StyleGraph;
import remixlab.remixvym.core.graphics.link.LineLink;
import remixlab.remixvym.core.graphics.link.LinkGraph;
//import remixlab.remixvym.core.graphics.multimedia.HelpInfo;
import remixlab.remixvym.core.graphics.node.*;
import remixlab.remixvym.core.help.help;
//import remixlab.remixvym.core.graphics.text.TextUtil;
import remixlab.remixvym.core.mindmap.Node;
import remixlab.remixvym.core.util.MindMapUtil;
import remixlab.remixvym.core.util.ScrolledUtil;
//import remixlab.remixvym.core.util.selected.FlatSelectedUtil;
//import remixlab.remixvym.core.util.selected.QuadSelectedUtil;
//import remixlab.remixvym.core.util.selected.SelectedUtil;
//import remixlab.remixvym.core.util.selected.TriangleSelectedUtil;
import remixlab.remixvym.xml.FileVymReader;
/** 
 * A processing 2D interactive scene. A Scene provides a default interactivity for 
 * your scene through the mouse and keyboard in the hope that it should fit most 
 * user needs. 
 * 
 * This Scene provides interactivity and with a Mind Map created in VYM (View Your Mind)
 * and allow visualize in a sketch of processing same that VYM
 */

public class SceneMindMap{
	
	/**The main constructor, use defaults settings.
	 * 
	 * <p>Use a default style colors 
	 * and shape of Mind Map (StyleGraph), Nodes and Links, the default Algorithm Selection (TRIANGLE) 
	 * and the default ScaleMode (REAL). This constructor does not specify rendering used 
	 * in the Sketch, this work is assigned to user in sketch.</p><br>
	 * 
	 * <b>Style Nodes Used:</b> {@link remixlab.remixvym.core.graphics.node.RectNode}, {@link remixlab.remixvym.core.graphics.node.OvalNode} and 
	 * {@link remixlab.remixvym.core.graphics.node.NoneNode}<br><br>
	 * <b>Style Links Used:</b> {@link remixlab.remixvym.core.graphics.link.TriangleLink} with parameter (1,2 and 4), 
	 * {@link remixlab.remixvym.core.graphics.link.OvalLink} and {@link remixlab.remixvym.core.graphics.link.LineLink}<br><br><br>
	 * <b>See more:</b>{@see remixlab.remixvym.core.graphics.StyleGraph}<br><br><br>
	 * 
	 * @param ap The sketch reference
	 */
	
	
	public SceneMindMap(PApplet ap) {
		parent=ap;
		style = new StyleGraph();
		style.initDeafult(parent);
		// Adds the default node styles available.
		style.addNodeStyle(new RectNode());
		style.typeNode = 0;
		style.addLinkStyle(new LineLink());
		style.typeLine = 0;
		
		this.constructora();
	}

	/**Specific constructor, use render P2D, set the size of sketch as its parent's size and set a custom Style. 
	 * Use the default Algorithm Selection (TRIANGLE) 
	 * and the default ScaleMode (REAL). This constructor specify the custom Style ({@link remixlab.remixvym.core.graphics.StyleGraph}).
	 * <br><br><br>
	 * 	  
	 * <b>See Examples:</b> Colors, LineStyle and NodeStyle<br><br>
	 * 
	 * @param ap The sketch reference
	 * @param style Custom Style
	 */
	public SceneMindMap(PApplet ap,StyleGraph estilo){
		parent = ap;
		this.style = estilo;
		style.initFonts(parent);
		// Adds the default node styles available.
		style.addNodeStyle(new RectNode());
		style.typeNode = 0;
		style.addLinkStyle(new LineLink());
		style.typeLine = 0;
		
		this.constructora();
	}
	
	/**El constructor NO esta contemplado por ahora
	 * Specific constructor, use render P2D and set the size of sketch. 
	 * Use the defaults Selection Algorithm and scale mode. 
	 * 
	 * @param ap The sketch reference
	 * @param wx Width of Scene
	 * @param hy Height of Scene
	 * */
	public SceneMindMap(PApplet ap, int wx, int hy){
		//Cuando se reemplace esto acuerdese de lanzar la correspondiente excepcion
		try{
			this.constructora();
		}
		catch (Exception e){
			System.err.println("Problemas al inicializar valores, " +
					"puede ser que " +
					"el contructor que esta usando se encuentra " +
					"en construccion  " + e.toString());
		}
	}
	
	/*
	 * ayuda a estandarizar los constructores
	 */
	private void constructora(){
		
		parent.addMouseWheelListener(new java.awt.event.MouseWheelListener() { 
		    public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { 
		      mouseWheel(evt.getWheelRotation());
		  }});
		
		contador =0;//una variable de pruebas para acciones del mouse y teclado
		//we declare active the little window with all map
		this.mapfullActive = true;
		
		PG_Image = parent.createGraphics(0,0,PApplet.P2D);
		map_auxiliar = parent.createGraphics(parent.width,parent.height,PApplet.P2D);
		mapfull = parent.createGraphics(
				PApplet.round((float)(parent.width)/3.0f),
				PApplet.round((float)(parent.height)/3.0f),PApplet.P2D);
		
		height = mapfull.height;
		width = mapfull.width;
		
		mapfull.textMode(PConstants.SCREEN);
		map_auxiliar.textMode(PConstants.SCREEN);
		
		mode = MindMapUtil.REAL;
		
		parent.registerKeyEvent(this);
		parent.registerMouseEvent(this);
		
		//se le da el tamaño por defecto de la ventana
		x1=0;x2=mapfull.width;y1=0;y2=mapfull.height;
		//se calcula la constante
		K = PApplet.max(PApplet.abs(x1-x2),PApplet.abs(y1-y2));
		K = (float)(this.map_auxiliar.width)/K;
		
		//se calula el acumulado respectivo
		add = (float)(x2)/(float)(mapfull.width);
		//se inicializa K
		this.computeK();
	}
	
	public void setScaleMode(int mod)
	{
	   mode =mod;
	}
	
	/**
	 * Changes the selection mode using the index of available algorithms.
	 * */
	public void setAlgorithmSelection(int alg)
	{
		//selAlgoritm =alg;
	}

	/**
	 * Associate a processed {@link MindMap} to the scene
	 * 
	 * @param ma MindMap instance
	 * */
	
	public void setMap(MindMap ma) {
		map = ma;
		init();
		map.getMap().selected=true;
		selected = map.getMap();
		this.paint_mapfull();
		this.paint_map_auxiliar();
	}

	/*
	 * call to setMapfull and setMap_window
	 */
	public void setMap(String file){
		fileVYM=file;
		setMapfull(fileVYM);
		map.getMap().selected=true;
		selected = map.getMap();
		this.paint_mapfull();
		this.paint_map_auxiliar();
	}
	/**
	 * Associate a {@link MindMap} to the scene from a non-processed file.
	 * @param file The filename of the mind map
	 * */
	private void setMapfull(String file) {
		
		map = new MindMap();
		PXMLReader xmlReader = new PXMLReader(parent);
		
		if(file.substring(file.length()-3, file.length()).equals("xml"))
		{
			map.create(file, xmlReader);
		}else if(file.substring(file.length()-3, file.length()).equals("vym"))
		{
			utilFile = new FileVymReader(parent,file);
			//map.create(utilFile.getName()+".xml",utilFile.getXML(),xmlReader);
			
			//las siguientes lineas del ciclo son inventadas por cristian
			file = utilFile.getName()+".xml";
			map.create(file, xmlReader);
		}
		
		init();
	}
	
	/**
	 * Initializes the map and flags like blocked (used when it is showing videos, help, images or sketches) 
	 * */
	public void init() {
		
		parent.frameRate(30);
		//message
		contMsg = 0;
		//msg= "";
		
		//Creates the handler to control some features. 
		handlerNode = new NodeGraph(style);
		handlerLink = new LinkGraph(style);
		scrolledUtil = new ScrolledUtil();
		
		//Init map, using MindMapUtil to apply a style to the map.
		mapUtil = new MindMapUtil();
		mapUtil.beginMap(map,style);
		organize();
		computeRXRY();
	}
	
	/**
	 * Configures the map area and update the scale factor used in style and scale management. 
	 * */
	private void organize()
	{
		mapUtil.changeSize(map,width, height,mode);
		style.changeScale(parent, map.getScale());
		scrolledUtil.changeScale(map.getScale());
	}
	
	private void computeRXRY(){
		RX= (float)(mapfull.width)/(float)(map.getWidthOriginal());
		RY= (float)(mapfull.height)/(float)(map.getHeightOriginal());
	}

	/**
	 * Do the painting using the style properties and activate sketch, video, image or help modes when needed.
	 * Called automatically every frame.
	 * */ 
	public void paint() {
		
		this.paint_map_auxiliar();
		parent.imageMode(PApplet.CORNER);
		parent.image(this.map_auxiliar,0,0);
		if(this.mapfullActive){
			this.paint_mapfull();
			parent.image(this.mapfull,0,map_auxiliar.height-mapfull.height);
		}
		parent.imageMode(PApplet.CENTER);
		parent.image(this.PG_Image,map_auxiliar.width/2,map_auxiliar.height/2);
	}
	
	/**
	 * Do the painting in the PGraphics mapfull using the style properties and activate sketch, video, image or help modes when needed.
	 * Called automatically every frame.
	 * */
	public void paint_mapfull() {
		//Recursive painting, starting from the root of the map.
		mapfull.beginDraw();
		//mapfull.background(style.rBackgraund, style.gBackgraund,style.bBackgraund);
		mapfull.background(0, style.gBackgraund,style.bBackgraund);
		paintNode(map.getMap());
		if(dragging){
			mapfull.stroke(204, 102, 0);	
		}
		mapfull.rectMode(PApplet.CORNERS);
		mapfull.noFill();
		mapfull.rect(x1,y1,x2,y2);
		mapfull.stroke(0);
		mapfull.fill(30);
		mapfull.endDraw();
		
		imagenToggle = parent.loadImage("resources/indice.jpeg");
		mapfull.image(imagenToggle,0,mapfull.height-wideButton,
				this.wideButton,this.wideButton);
	}
	
	
	/*
	 * this function is one remake of paint_map for map_auxiliar
	 */
	public void paint_map_auxiliar() {
		
		//Recursive painting, starting from the root of the map.
		
		map_auxiliar.beginDraw();
		computeStroke();
		map_auxiliar.background(style.rBackgraund, style.gBackgraund,style.bBackgraund);
		map_auxiliar.pushMatrix();
		map_auxiliar.scale(K);
		map_auxiliar.pushMatrix();
		map_auxiliar.translate(-x1,-y1);
		int dx = PApplet.round((-x1)*K);
		int dy = PApplet.round((-y1)*K);
		paintNode_auxiliar(map.getMap(),K,dx,dy);
		map_auxiliar.popMatrix();
		map_auxiliar.popMatrix();
		map_auxiliar.rectMode(PApplet.CORNERS);
		map_auxiliar.noFill();
		map_auxiliar.rect(5,5,map_auxiliar.width-5,map_auxiliar.height-5);
		map_auxiliar.stroke(0);
		map_auxiliar.endDraw();
	}
	
	private void computeStroke(){
		
		float WW = PApplet.abs(x1-x2);
		float WH = PApplet.abs(y1-y2);
		
		map_auxiliar.strokeWeight(1);
		if(WW<=500*RX || WH<=500*RY){
			map_auxiliar.strokeWeight(2);
		}
		if(WW<=300*RX || WH<=300*RY){
			map_auxiliar.strokeWeight(3);
		}
		if(WW<=200*RX || WH<=200*RY){
			map_auxiliar.strokeWeight(4);
		}
	}
	

    private void image(){
    	if(utilFile!=null)
    	{
    		myImage = utilFile.getImage(selected.contImage);
    	}else
    	{
    		String urlResources = "images/" + selected.contImage;
    		myImage = parent.loadImage(urlResources);
    		this.PG_Image = parent.createGraphics(
    				myImage.width,myImage.height,PApplet.P2D);
    		PG_Image.beginDraw();
    		PG_Image.image(myImage,0,0);
    		PG_Image.endDraw();
    	}
	}
	
    /**
     * Draws the help content of {@link #help}
     * */
    private void showHelp(){
		
		parent.fill(0, 0, 0, 220);
		parent.stroke(0, 0, 0, 220);
		parent.rect(0, 0, width, height);
		float y = (height / 4);
		float x = (width / 4);
		
		parent.fill(250);
		parent.stroke(0, 0, 0);
		parent.textFont(style.fontOther);
		parent.text("" +help.getHelpInfo(), x, y );
	}


    /**
     * recursively draws the section of the mapfull that begin in the {@link remixlab.remixvym.core.mindmap.Node}
     * 
     * @param node The starting painting node. Use {@link #map.getMap()} to full tree painting 
     * */
    private void paintNode(Node node) {
		int color = ConstansColor.NonSelect;
		
		//Do the same for children
		for (int i = 0; i < node.children.size(); i++) {
			paintNode(node.children.get(i));
		}
		
		if(node.nodeStyle.equals("")){
			handlerNode.drawNode(node, parent, color, mapfull);
		}
		else{
			handlerNode.drawNode(node, parent, color, getNodeType(node.nodeStyle),mapfull);
		}
		handlerLink.drawLink(node, parent,mapfull);
	}
	
        
    /*
     * funcion que corre el paint auxiliar
     */
    private void paintNode_auxiliar(Node node, float K, int dx, int dy) {
    	
		int color = ConstansColor.NonSelect;

		//Do the same for children
		for (int i = 0; i < node.children.size(); i++) {
			paintNode_auxiliar(node.children.get(i),K,dx,dy);
		}
		if(node.nodeStyle.equals("")){
			handlerNode.drawNode_auxiliar(node, parent, color, map_auxiliar,K,dx,dy);
		}
		else{
			handlerNode.drawNode(node, parent, color, getNodeType(node.nodeStyle),map_auxiliar);
		}
		handlerLink.drawLink(node, parent,map_auxiliar);
	}
    
	/**
	 * Set the mapping among tag values and the default kind of nodes
	 * */
	//TODO: Do it flexible. It requires use of Class.forName() and advanced java classes management
	public int getNodeType(String s){
		int ntIndex = style.typeNode;
		if(s.equalsIgnoreCase("rect")){
			ntIndex = style.findStyle("RectNode");
		}
		else if(s.equalsIgnoreCase("callout")){
			ntIndex = style.findStyle("CalloutNode");
		}
		else if(s.equalsIgnoreCase("twoOval")){
			ntIndex = style.findStyle("DoubleOvalNode");
		}
		else if(s.equalsIgnoreCase("none")){
			ntIndex = style.findStyle("NoneNode");
		}
		else if(s.equalsIgnoreCase("oval")){
			ntIndex = style.findStyle("OvalNode");
		}
		else if(s.equalsIgnoreCase("rfish")){
			ntIndex = style.findStyle("RFishHeadNode");
		}
		else if(s.equalsIgnoreCase("roundedrect")){
			ntIndex = style.findStyle("RoundedRectNode");
		}
		return ntIndex;
	}
	
	/*
	 * manage the size of the window
	 */
	public void mouseWheel(int entero){
		
		add = add+(-1)*(float)(entero)/100;
		
		float medida=mapfull.width;
		medida = medida*add;
		x2 = x1+PApplet.round(medida);
		
		medida=mapfull.height;
		medida = medida*add;
		y2 = y1+PApplet.round(medida);
		this.computeK();
	}
	
	/*
	 *select the node in those coordinates 
	 */
	public void mouseClicked(int x, int y){
		
		if(x < wideButton && y>mapfull.height-wideButton){
			parent.key = 'i';
			key_Typed();
		}else{
			selectNode(x,y,map.getMap());
		}
	}
	
	private void selectNode(int X, int Y, Node nodo){
		
		int nodoX1 = PApplet.round(nodo.x1*K + -x1*K);
		int nodoY1 = PApplet.round(nodo.y1*K + -y1*K);
		int nodoX2 = PApplet.round(nodo.x2*K + -x1*K);
		int nodoY2 = PApplet.round(nodo.y2*K + -y1*K);
		
		if(X>nodoX1 && Y>nodoY1){
			if(X<nodoX2 && Y<nodoY2){
				this.selected.selected=false;
				this.selected= nodo;
				selected.selected = true;
			}
		}
		//do the same for its children
		for(int index =0;index< nodo.children.size();index++){
			selectNode(X,Y,nodo.children.get(index));
		}
	}
	
	public void execute(){
		//selected.
	}
	
	/*
	 * manage the window location
	 */
	public void mouse_Dragged(){
		//si la ventana de navegacion esta activa
		if(!this.mapfullActive){
			int dx= parent.mouseX-parent.pmouseX;
			int dy= parent.mouseY-parent.pmouseY;
			//ahora aplicamos el escalamiento a la inversa
			dx = -1*PApplet.round((float)(dx)*(1.0f/this.K));
			dy = -1*PApplet.round((float)(dy)*(1.0f/this.K));
			x1=x1+dx;
			x2=x2+dx;
			y1=y1+dy;
			y2=y2+dy;
			return;
		}
		//inicializamos variables
		int mouseX = parent.mouseX;
		int mouseY = parent.mouseY-(parent.height-mapfull.height);
		int PmouseX = parent.pmouseX;
		int PmouseY = parent.pmouseY-(parent.height-mapfull.height);
		if(mouseX>x1 && mouseY>y1 && mouseX<x2 && mouseY<y2){
			//cambiamos el valor de dragging
			dragging = true;
			
			int dx= mouseX-PmouseX;
			int dy= mouseY-PmouseY;
			x1=x1+dx;
			x2=x2+dx;
			y1=y1+dy;
			y2=y2+dy;
			return;
		}
	}
	
    public void mouseEvent(MouseEvent event) {

            switch (event.getID()) {
            case MouseEvent.MOUSE_DRAGGED:
                mouse_Dragged();
                break;
            case MouseEvent.MOUSE_RELEASED:
            	mouseReleased();
                break;
            case MouseEvent.MOUSE_CLICKED:
            	mouseClicked(parent.mouseX,parent.mouseY);
            default:
                break;
            }
        }
	
	
	/*
	 * se encarga de ejecutar el mouseReleased de processing
	 */
	public void mouseReleased(){
		dragging=false;
	}
	
	/*
	 * this function is a matter of formality
	 */
	public void keyEvent(KeyEvent evento){
		//cuando lo hago con key_Pressed llama dos veces 
		if (evento.getID() == KeyEvent.KEY_RELEASED){
			contador++;
			this.key_Typed();
		}
	}
	
	/**
	 * Defines the action mapping (Hotkeys) between useful commands or modes and keys in a keyboard.
	 * 
	 * Default Hotkeys:
	 * <ul>
	 * <li>s: Shows a processing sketch if available in the selected node</li>
	 * <li>i: Shows a processing image if available in the selected node</li>
	 * <li>v: Shows a processing video if available in the selected node</li>
	 * <li>h: Shows help</li>
	 * </ul>
	 * */
	public void key_Typed(){
		switch (parent.key){		
		case 's':
			//callSketch();
			break;
		case 'S':
			//callSketch();
			break;
		case 'i':
			callImage();
			break;
		case 'I':
			callImage();
			break;
		case 'h':
			callHelp();
			break;
		case 'H':
			callHelp();
			break;
		case 'v':
			//callVideo();
			break;
		case 'V':
			//callVideo();
			break;
		case 'c':
			this.mapfullActive = !this.mapfullActive;
			break;
		default:
			
			break;
		}
		
		if(parent.keyCode == PApplet.DOWN){
			System.out.println("debo bajar"+contador);
		}
	}
	
	/**Action methods*/
	private void callImage(){
		if (selected.contImage != null) {
			this.PG_Image = parent.createGraphics(0,0,PApplet.P2D);
			if(selected.showImage){
				selected.showImage = false;
			}
			else
			{
				selected.showImage = true;
				image();
			}
		}
	}
	
	private void callHelp(){
		if(helpStart){
			helpStart = false;
		}
		else 
			helpStart = true;
		showHelp();				
	}
	
	public StyleGraph getStyleMap(){
		return style;
	}
	
	/**
	 * Returns the {@link MindMap} associated to the scene
	 * */
	public MindMap getMap(){
		return map;
	}
	
	/**
	 * devuelve el PGraphic que contiene el mapa completo
	 * @return
	 */
	public processing.core.PGraphics getMapfull(){
		return mapfull;
	}
	
	/**
	 * devuelve el PGraphic que contiene el mapa de la ventana
	 * @return
	 */
	public processing.core.PGraphics getMap_auxiliar(){
		return map_auxiliar;
	}
	
	public void setEmbedding(){
		//embedding = true;
	}
	
	/*
	 * returns the PGraphics with the image
	 */
	public processing.core.PGraphics getImage(){
		return PG_Image;
	}
	
	/*
	 * calcula la variable de escalamiento
	 */
	public void computeK(){
		//compute the constant K for the Scale;
		float absX=PApplet.abs(x1-x2);
		float absY=PApplet.abs(y1-y2);
		if(absX>absY){
			K = (float)(map_auxiliar.width)/absX;
		}
		K = (float)(map_auxiliar.height)/absY;
	}
	
	/**The main applet containing the scene (A Processing sketch)*/
	private PApplet parent;
	/**The mapfull's object representation*/
	private MindMap map;
	/**PGraphics with hole map*/
	private PGraphics mapfull;
	/**PGraphics with the window_aux  view*/
	private PGraphics map_auxiliar;
	/**StyleGraph defines all the style variables. See {@link remixlab.remixvym.core.graphics.StyleGraph}*/
	private StyleGraph style;
	/**PGraphics with the window_aux  view*/
	private PGraphics PG_Image;
	private int mode;
	/**Width of the mapfull,*/
	private int width = 0;
	/**height of the mapfull*/
	private int height = 0;
	
	//Utilities and handlers
	/**Tool for reading .vym files*/
	private FileVymReader utilFile;
	/**Tool for managing map's properties*/
	private MindMapUtil mapUtil;
	/**Tool for managing node's properties*/
	private NodeGraph handlerNode;
	/**Tool for managing links' properties*/
	private LinkGraph handlerLink;
	/**Tool for managing selection algorithm*/
	//private SelectedUtil selectedUtil;
	/**Tool for managing scroll feature*/
	private ScrolledUtil scrolledUtil;
	
	//Selection options
	/**Selected and focused node in the map*/
	private Node selected;
	
	//Blocked only let you show special modes and the default drawing and selection modes.
	/**If true you just can draw the map and activate sketches, images, videos and help. No editing, no changes in selection algorithm, and so on are not available*/
	//private boolean blocked;
	/**True if mouse has been pressed*/
	//private boolean pressed;
	/**If true, you can move the nodes dragging them when selected*/
	//private boolean editMode;
	/**id of the selection algorithm used*/
	//private int selAlgoritm;
	/**Name of the Sketch class to show*/
	//private String mySketch;
	/**Indicates whether sketches are embedded into mind maps*/
	//private boolean embedding = false;
	/**Image*/
	private PImage myImage;
	
	//Video
	/**Tool for managing video*/
	//private VideoUtil myMovie;
	
	//Help
	/**Tool for managing help info*/
	//private HelpInfo help = new HelpInfo();
	private help help = new help();
	/**If true, help is shown at the beginning of the scene*/
	private boolean helpStart =false;
	/**coordinate x of vertex upper left */
	private int x1 = 0;
	/**coordinate y of vertex upper left */
	private int y1 = 0;
	/**coordinate x of vertex lower right */
	private int x2 = 0;
	/**coordinate x of vertex lower right */
	private int y2 = 0;
	/**constant used for scale */ 
	private float K;
	//Message 
	/**Counter of messages shown*/
	int contMsg;
	/**Message content*/
	/**true if the mouse is dragging the window*/
	private boolean dragging;
	/**keep the resize*/
	private float add;
	/**contain the String file VYM*/
	private String fileVYM;
	//private String msg;
	/**determina el ancho del boton de imagen*/
	private final float wideButton=30;
	/** detrmina si la ventana pequeña sera visible*/
	private boolean mapfullActive;
	private int contador;
	/**guardan las contantes de escalamiento del mapa original al mapfull*/
	private float RX,RY;
	/**Image que guarda la imagen del toogle*/
	private PImage imagenToggle;
}
